<template lang="jade">
h-loader-full(url='loader',:setdata='false')
  h-data-lister(data='list')
  .box
    //查询
    m-title(icon='add',name='培训课期列表')
      select(v-model='p.sid',placeholder='请选择所属培训学校',@click='link')
        option(value='', selected) 请选择所属培训学校
        option(v-for='(n,i) in school', :value='n.id') {{n.name}}
      select(v-model='p.culid',placeholder='请选择所属培训课程')
        option(value='', selected) 请选择所属培训课程
        option(v-for='(n,i) in cultivate', :value='n.id') {{n.name}}
      select(v-model='p.ishistory',placeholder='往期课期')
        option(value='', selected) 请选择是否为往期
        option(v-for='(n,i) in ishistory', :value='i') {{n}}
      select(v-model='p.show',placeholder='显示位置')
        option(value='', selected) 请选择显示位置
        option(v-for='(n,i) in show', :value='i') {{n}}
      input(type = 'text',v-model='p.name',placeholder='请填写课期名称',style='width:95px;')
      button(@click='goFilter(p)') 过滤
    //人员信息
    table.list
      ml-header(data='序号,所属学校名称,所属课程名称,课期显示位置,课期名称,课期开始时间,课期结束时间,报名结束时间,是否为往期,操作')
      tr(v-for='(n,i) in list')
        td {{n.id}}
        td {{n.sname}}
        td {{n.culname}}
        td {{show[n.show]}}
        td {{n.name}}
        td {{ new Date(n.class_starttime*1000).format('yyyy-MM-dd hh:mm:ss') }}
        td {{ new Date(n.class_endtime*1000).format('yyyy-MM-dd hh:mm:ss') }}
        td {{ new Date(n.apply_endtime*1000).format('yyyy-MM-dd hh:mm:ss') }}
        td {{ishistory[n.ishistory]}}
        td
          a(:href="'./semester_edit.html?semid=' + n.id") 编辑
    .command
      .page
        button(v-show='page>1', @click="pagego('last')") 上一页
        button {{page}}
        button(@click="pagego('next')") 下一页
</template>
----------------------------------------------------------------------------------------
<script>
import { MessageBox } from 'mint-ui'
export default {
	data () {
		return {
			loader:{
        school:'cultivate/school/list',
        list:'cultivate/semester/list',
      },
      school:[],
      list:[],
      cultivate:[],
      show:['两端显示','用户端','企业端'],
      p:{
        sid:'',
        culid:'',
        name:'',
        ishistory:'',
        show:'',
      },
      ishistory:['否','是'],
      page:1,
		}
	},
  mounted () {

  },
	methods: {
		loadAfter(data){
      this.school = data.school[0]
      this.list = data.list[0]
		},
    updataAfter (res) {
			this.$msg.success()
			setTimeout("window.location.reload()",1000)
		},
    //过滤
    goFilter (p) {
			this.$ajax.get('cultivate/semester/list?sid='+ this.p.sid + '&culid=' + this.p.culid + '&ishistory=' + this.p.ishistory + '&name=' + this.p.name + '&show=' + this.p.show, (res) => {
				this.list = res.data[0]
        this.page = 1
			}, (res) => {
				this.error(res.message)
			})
		},
    // 分页
    pagego (type) {
      this.page = type == 'last' ? this.page - 1 : this.page + 1
      this.$ajax.get('cultivate/semester/list?sid='+ this.p.sid + '&culid=' + this.p.culid + '&ishistory=' + this.p.ishistory + '&name=' + this.p.name + '&show=' + this.p.show + '&page=' + this.page, (res) => {
        this.list = res.data[0]
      }, (res) => {
        this.error(res.message)
      })
    },
    // 联动
    link(){
      this.$ajax.get('cultivate/cultivate/list?sid='+ this.p.sid , (res) => {
        this.cultivate = res.data[0]
      }, (res) => {
        this.error(res.message)
      })
    }
	}
}
</script>
----------------------------------------------------------------------------------------
<style lang="less" scoped>
@import "../../../plugin/style/mixin";
.page{ float:right; }
  .page a{background: #4db3ff; color: #fff; padding:3px 10px; border-radius:4px; cursor:pointer;}
  .page b{margin:0 10px;}
</style>